#include<iostream>
#include<cstring>

using namespace std;
typedef long long LL;
const int N = 1e5 + 10;

int n;
int a[N], b[N], c[N];
int s[N], aa[N], cc[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]++;
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        c[i]++;
    }
    for (int i = 0; i < n; ++i) {
        s[a[i]]++;
    }
    for (int i = 0; i < N; ++i) {
        s[i] += s[i - 1];
    }
    for (int i = 0; i < n; ++i) {
        aa[i] = s[b[i]];
    }
    memset(s, 0, sizeof s);
    for (int i = 0; i < n; ++i) {
        s[c[i]]++;
    }
    for (int i = 0; i < N; ++i) {
        s[i] += s[i - 1];
    }
    for (int i = 0; i < n; ++i) {
        cc[i] = n - s[b[i] + 1];
    }
    long long res = 0;
    for (int i = 0; i < n; ++i) {
        res += aa[i] * cc[i];
    }
    cout << res << endl;
}
